<?php

/***********************************************************
 * 
 ***********************************************************/
class PRokkoMVC {
   
   /***********************************************************
    * @param $pNs string plugin namespace
    * @param $pDefController string name of default controller, in case none is specified in request
    * @param $pPluginName string name of plugin, as registered in WordPress
    * @param $pAddDir string absolute path to application
    * @param $pWpdb WPDB native database interface provided by WordPress
    * @param $pReqName $_REQUEST the request object sent via the HTTP request
    **********************************************************/
   static function run($pNs, $pDefController, $pPluginName, $pAppDir, $pWpdb, $pParam) {
      $param = explode("@", $pParam);

      //
      // If no params, then we're on main dashboard
      //
      if (count($param) < 2){
         $ctlr = "\\{$pNs}\\{$pDefController}Controller";
         $controller = new $ctlr($pWpdb, $pPluginName, $pAppDir);
         $controller->index();
      } else {
         $ctlr = "\\{$pNs}\\{$param[1]}Controller";
         $controller = new $ctlr($pWpdb, $pPluginName, $pAppDir);
         $controller->$param[0]();
      }
   }
}
